#include <iostream>
using namespace std;

/*
    创建子类的时候，是先构建父类，再构建子类
        父类默认调用无参构造函数
        子类根据实际调用相应的构造函数
    注意：如果父类中没有无参构造函数，子类就无法创建    编译出错
    指定调用父类的构造函数，在子类的构造函数后面添加 : 父类构造函数(参数列表)
        即：子类构造函数 : 父类构造函数(参数列表) ==> 调用父类带参构造函数
*/

class Animal
{
public:
    Animal()
    {
        cout << "Animal()" << endl;
    }
    Animal(string _name , int _age)
    {
        name = _name;
        age = _age;
        cout << "Animal(string _name , int _age)"<<endl;
    }
    void show()
    {
        cout << "name:" << name << " age:" << age << endl;
    }
    string name;
    int age;
};

class Cat : public Animal
{
public:
    Cat():Animal("小白",12)
    {
        weight = 0;
        cout << "Cat()" << endl;
    }
    Cat(double _weight,string _name , int _age):Animal(_name,_age)
    {
        weight = _weight;
        cout << "Cat(string _name , int _age)"<< endl;
    }
    void showCat()
    {
       show();
       cout << "weight:" << weight << endl;
    }
private:
    double weight;
};


int main()
{
    Cat c1(12,"猫",2);
    Cat c2;
    c1.showCat();
    c2.show();


    return 0;
}